package com.smart.web.controller.system;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.smart.common.core.page.PageQuery;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

import java.util.Arrays;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.smart.common.annotation.Log;
import com.smart.common.core.controller.BaseController;
import com.smart.common.core.domain.AjaxResult;
import com.smart.common.enums.BusinessType;
import com.smart.common.core.domain.R;
import com.smart.system.domain.CarClassify;
import com.smart.system.service.ICarClassifyService;
import com.smart.common.utils.poi.ExcelUtil;
import com.smart.common.core.page.TableDataInfo;

/**
 * 车辆分类Controller
 * 
 * @author smart
 * @date 2025-01-14
 */
@RestController
@RequestMapping("/system/classify")
@Api(tags = "车辆分类")
public class CarClassifyController extends BaseController
{
    @Autowired
    private ICarClassifyService carClassifyService;

    /**
     * 查询车辆分类列表
     */
    @ApiOperation(value = "查询车辆分类列表")
    @GetMapping("/page")
    public R<IPage<CarClassify>> list(PageQuery pageQuery)
    {
        IPage<CarClassify> page = carClassifyService.page(pageQuery.toPage());
        return R.ok(page);
    }

    /**
     * 新增车辆分类
     */
    @ApiOperation(value = "新增车辆分类")
    @Log(title = "车辆分类", businessType = BusinessType.INSERT)
    @PostMapping
    public R<Boolean> add(@RequestBody CarClassify carClassify)
    {
        return R.ok(carClassifyService.save(carClassify));
    }

    /**
     * 删除车辆分类
     */
    @ApiOperation(value = "删除车辆分类")
    @Log(title = "车辆分类", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public R<Boolean> remove(@PathVariable String[] ids)
    {
        return R.ok(carClassifyService.removeByIds(Arrays.asList(ids)));
    }
}
